package org.zfes.snowier.cloud.zbss.widget.act.route.service.stu;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.widget.act.model.ActQuestion;
import org.zfes.snowier.cloud.zbss.widget.act.service.IActQuestionService;
@Controller 
@RequestMapping("/active/actQuestion")
public class ActQuestionController extends BaseController {

	
	@Autowired
	private IActQuestionService actQuestionService;
	
	@RequiresPermissions(value="actQuestion:loadActQuestionDataSet",desc="问题列表")
    @RequestMapping(value="/loadActQuestionDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadActQuestionDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  actQuestionService.loadActQuestionDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="actQuestion:createActQuestion",desc="问题添加")
    @RequestMapping(value="/createActQuestion", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createActQuestion(ActQuestion actQuestion){
		actQuestionService.createActQuestion(actQuestion);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="actQuestion:loadActQuestion",desc="问题加载")
    @RequestMapping(value="/loadActQuestion", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadActQuestion(Long id){
		Optional<ActQuestion> ops = actQuestionService.loadActQuestionById(id);
		return ajaxQuery("actQuestion",ops);
    }
	
	@RequiresPermissions(value="actQuestion:updateActQuestion",desc="问题更新")
    @RequestMapping(value="/updateActQuestion", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateActQuestion(ActQuestion actQuestion){
		actQuestionService.updateActQuestion(actQuestion);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="actQuestion:deletActQuestion",desc="问题删除")
    @RequestMapping(value="/deleteActQuestion", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteActQuestion(Long id){
		actQuestionService.deleteActQuestion(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}